//
//  NMPOSpeedResultInfoCell.swift
//  NMPO
//
//  Created by PowerfullClean on 2023/10/31.
//

import UIKit

class NMPOSpeedResultInfoCell: NMPOScanResultInfoCell {
    override init(frame: CGRect) {
        super.init(frame: frame)
        nmpo_iconView3.addSubview(nmpo_downloadView)
        nmpo_iconView3.addSubview(nmpo_uploadView)
        nmpo_iconView3.addSubview(nmpo_pingView)
        nmpo_iconView3.addSubview(nmpo_lossView)
        nmpo_iconView3.addSubview(nmpo_jitterView)
        nmpo_downloadView.snp.makeConstraints { make in
            make.width.equalTo(nmpo_w/2.0)
            make.left.equalToSuperview().offset(56)
            make.top.equalToSuperview()
            make.height.equalTo(66)
        }
        nmpo_uploadView.snp.makeConstraints { make in
            make.width.equalTo(nmpo_w/2.0)
            make.right.equalToSuperview()
            make.top.equalToSuperview()
            make.height.equalTo(66)
        }
        nmpo_pingView.snp.makeConstraints { make in
            make.width.equalTo(nmpo_w/3.0)
            make.left.equalToSuperview().offset(56)
            make.bottom.equalToSuperview()
            make.height.equalTo(66)
        }
        nmpo_lossView.snp.makeConstraints { make in
            make.width.equalTo(nmpo_w/3.0)
            make.centerX.equalToSuperview()
            make.bottom.equalToSuperview()
            make.height.equalTo(66)
        }
        nmpo_jitterView.snp.makeConstraints { make in
            make.width.equalTo(nmpo_w/3.0)
            make.right.equalToSuperview()
            make.bottom.equalToSuperview()
            make.height.equalTo(66)
        }
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    var nmpo_speedValueModel: NMPOSpeedValueModel? {
        didSet {
            guard let nmpo_speedValueModel = nmpo_speedValueModel else { return }
            nmpo_downloadView.nmpo_valueLabel.text = nmpo_speedValueModel.nmpo_download
            nmpo_uploadView.nmpo_valueLabel.text = nmpo_speedValueModel.nmpo_upload
            nmpo_pingView.nmpo_valueLabel.text = nmpo_speedValueModel.nmpo_ping
            nmpo_lossView.nmpo_valueLabel.text = nmpo_speedValueModel.nmpo_loss
            nmpo_jitterView.nmpo_valueLabel.text = nmpo_speedValueModel.nmpo_jitter
//            if  NMPOManager.nmpo_manager.nmpo_vpnCurStateType == .nmpo_connected {
//                nmpo_pingView.isHidden = true
//                nmpo_lossView.isHidden = true
//                nmpo_jitterView.isHidden = true
//                nmpo_downloadView.snp.remakeConstraints { make in
//
//                    make.width.equalTo(nmpo_w/2.0)
//                    make.left.equalToSuperview().offset(56)
//                    make.top.equalToSuperview()
//                    make.bottom.equalToSuperview()
//                }
//                nmpo_uploadView.snp.remakeConstraints { make in
//                    make.width.equalTo(nmpo_w/2.0)
//                    make.right.equalToSuperview()
//                    make.top.equalToSuperview()
//                    make.bottom.equalToSuperview()
//                }
//            }
        }
    }
    lazy var nmpo_downloadView: NMPOTestResultInfoItemView = {
        let nmpo_downloadView = NMPOTestResultInfoItemView()
        nmpo_downloadView.nmpo_titleLabel.text = "Download"
        nmpo_downloadView.nmpo_valueLabel.text = "0"
        return nmpo_downloadView
    }()
    lazy var nmpo_uploadView: NMPOTestResultInfoItemView = {
        let nmpo_uploadView = NMPOTestResultInfoItemView()
        nmpo_uploadView.nmpo_titleLabel.text = "Upload"
        nmpo_uploadView.nmpo_valueLabel.text = "0"
        return nmpo_uploadView
    }()
    lazy var nmpo_pingView: NMPOTestResultInfoItemView = {
        let nmpo_pingView = NMPOTestResultInfoItemView()
        nmpo_pingView.nmpo_titleLabel.text = "Ping"
        nmpo_pingView.nmpo_valueLabel.text = "0"
        return nmpo_pingView
    }()
    lazy var nmpo_lossView: NMPOTestResultInfoItemView = {
        let nmpo_lossView = NMPOTestResultInfoItemView()
        nmpo_lossView.nmpo_titleLabel.text = "Loss"
        nmpo_lossView.nmpo_valueLabel.text = "0"
        return nmpo_lossView
    }()
    lazy var nmpo_jitterView: NMPOTestResultInfoItemView = {
        let nmpo_jitterView = NMPOTestResultInfoItemView()
        nmpo_jitterView.nmpo_titleLabel.text = "Jitter"
        nmpo_jitterView.nmpo_valueLabel.text = "0"
        return nmpo_jitterView
    }()
}

